#include "common.h"

int main()
{
    umask(0);
    int n=mkfifo("filename",0644);//建立管道
    if(n<0)
    {
        exit(5);
    }
    cout<<"aaaaaaa"<<endl;

    int a=open("filename",O_RDONLY);//这里是文件描述符
    if(a<0)
    {
        cout<<"error"<<endl;
        exit(6);
    }
    char buffer[128]={0};
    cout<<"aaaaaaa"<<endl;
    while(true)
    {
        cout<<"等待输入。。。"<<endl;
        ssize_t num=read(a,buffer,sizeof(buffer));
        if(num>0)
        {
            buffer[num-1]=0;
            cout<<"client say:"<<buffer<<endl;
        }
        else if(num==0)
        {
            cout<<"client quit"<<endl;
        }
        else
        {
            exit(2);
        }
    }

    return 0;
}
